﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace XDataBase.Demo.Data.Model
{
    public class BaseModel : INotifyPropertyChanged
    {
        #region 公共字段
        /// <summary>
        /// 自增编号
        /// </summary>
        public long ID { get; set; }

        /// <summary>
        /// 数据量
        /// </summary>
        public int DataCount { get; set; }
        #endregion

        #region 属性
        /// <summary>
        /// 当前页号
        /// </summary>
        public int pageNumber { get; set; }

        /// <summary>
        /// 每页记录数
        /// </summary>
        public int pageSize { get; set; }

        /// <summary>
        /// 分页查询用，起始行号
        /// </summary>
        public int startRowNumber
        {
            get
            {
                var val = (pageNumber - 1) * pageSize;
                if (val < 0) val = 0;
                return val + 1;
            }
        }

        /// <summary>
        /// 分页查询用，结束行号
        /// </summary>
        public int endRowNumber
        {
            get
            {
                var val = pageNumber * pageSize;
                if (val < 0) val = 0;
                return val;
            }
        }

        /// <summary>
        /// 全文检索
        /// </summary>
        public string fullTextSearch { get; set; }

        /// <summary>
        /// 排序字段
        /// </summary>
        public string sortColumn { get; set; }

        /// <summary>
        /// 排序模式
        /// </summary>
        public ListSortDirection sortDirection { get; set; }
        #endregion

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string name)
        {
            if (PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs(name));
        }
    }
}
